package com.ruoyi.web.controller.cems;

import com.ruoyi.cems.domain.BmsEVCContact;
import com.ruoyi.cems.service.IBmsEVCContactService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.UUID;

/**
 * 应急指挥部应急联络;Controller
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@RestController
@RequestMapping("/cems/contact")
public class BmsEVCContactController extends BaseController
{
    @Autowired
    private IBmsEVCContactService bmsEVCContactService;

    /**
     * 查询应急指挥部应急联络;列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BmsEVCContact bmsEVCContact)
    {
        startPage();
        List<BmsEVCContact> list = bmsEVCContactService.selectBmsEVCContactList(bmsEVCContact);
        return getDataTable(list);
    }

    /**
     * 导出应急指挥部应急联络;列表
     */
    @Log(title = "应急指挥部应急联络", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmsEVCContact bmsEVCContact)
    {
        List<BmsEVCContact> list = bmsEVCContactService.selectBmsEVCContactList(bmsEVCContact);
        ExcelUtil<BmsEVCContact> util = new ExcelUtil<BmsEVCContact>(BmsEVCContact.class);
        util.exportExcel(response, list, "应急指挥部应急联络;数据");
    }

    /**
     * 获取应急指挥部应急联络;详细信息
     */
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(bmsEVCContactService.selectBmsEVCContactByID(ID));
    }

    /**
     * 新增应急指挥部应急联络;
     */
    @Log(title = "应急指挥部应急联络", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsEVCContact bmsEVCContact)
    {
        bmsEVCContact.setID(UUID.randomUUID().toString().replace("-", ""));
        return toAjax(bmsEVCContactService.insertBmsEVCContact(bmsEVCContact));
    }

    /**
     * 修改应急指挥部应急联络;
     */
    @Log(title = "应急指挥部应急联络", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsEVCContact bmsEVCContact)
    {
        return toAjax(bmsEVCContactService.updateBmsEVCContact(bmsEVCContact));
    }

    /**
     * 删除应急指挥部应急联络;
     */
    @Log(title = "应急指挥部应急联络", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(bmsEVCContactService.deleteBmsEVCContactByIDs(IDs));
    }
}
